load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")

go_library(
    name = "gazelle_lib",
    srcs = [
        "diff.go",
        "fix.go",
        "fix-update.go",
        "gazelle.go",
        "langs.go",  # keep
        "metaresolver.go",
        "print.go",
        "profiler.go",
        "update-repos.go",
        "wspace.go",
    ],
    importpath = "github.com/stackb/rules_proto/cmd/gazelle",
    tags = ["manual"],
    visibility = ["//visibility:public"],
    deps = [
        "//cmd/gazelle/internal/module",
        "//cmd/gazelle/internal/wspace",
        "//language/protobuf",
        "@bazel_gazelle//config:go_default_library",
        "@bazel_gazelle//flag:go_default_library",
        "@bazel_gazelle//label:go_default_library",
        "@bazel_gazelle//language:go_default_library",
        "@bazel_gazelle//language/go:go_default_library",
        "@bazel_gazelle//language/proto:go_default_library",
        "@bazel_gazelle//merger:go_default_library",
        "@bazel_gazelle//repo:go_default_library",
        "@bazel_gazelle//resolve:go_default_library",
        "@bazel_gazelle//rule:go_default_library",
        "@bazel_gazelle//walk:go_default_library",
        "@com_github_pmezard_go_difflib//difflib",
    ],
)

go_binary(
    name = "gazelle",
    embed = [":gazelle_lib"],
    visibility = ["//visibility:public"],
)

go_test(
    name = "gazelle_test",
    srcs = [
        "diff_test.go",
        "fix_test.go",
        "integration_test.go",
    ],
    args = ["-go_sdk=go_sdk"],
    data = ["@go_sdk//:files"],
    embed = [":gazelle_lib"],
    deps = [
        "@bazel_gazelle//config:go_default_library",
        "@bazel_gazelle//testtools:go_default_library",
        "@io_bazel_rules_go//go/tools/bazel:go_default_library",
    ],
)

filegroup(
    name = "all_files",
    testonly = True,
    srcs = glob(["*.go"]) + [
        "BUILD.bazel",
        "//cmd/gazelle/internal/module:all_files",
        "//cmd/gazelle/internal/wspace:all_files",
    ],
    visibility = ["//:__pkg__"],
)
